`ifndef DRIVER_SVH
`define DRIVER_SVH

class driver #(parameter WIDTH = 4);
	virtual intf vif;
	extern virtual function build();
	extern virtual function connect(input virtual intf vif);
	extern virtual task main();
endclass

function driver::build();
endfunction

function driver::connect (input virtual intf vif);
	this.vif = vif;
endfunction

task driver::main();
	// 输出初始值
	vif.cb.a <= 'h0;
	vif.cb.b <= 'h0;
	// 等待复位结束
	@(posedge vif.rst_n);
	// 发送激励并采集响应
	repeat(5) begin
		@(vif.cb);
		vif.cb.a <= $urandom_range(0, 4'hf);
		vif.cb.b <= $urandom_range(0, 4'hf);
		$display("@%0t, a=%0d, b=%0d, sum=%0d", $time, vif.a, vif.b, vif.cb.sum);
	end
endtask

`endif
